package Game.GameElements 
{
	import Box2D.Collision.Shapes.b2MassData;
	import Box2D.Collision.Shapes.b2PolygonShape;
	import Box2D.Dynamics.b2Body;
	import Box2D.Dynamics.b2BodyDef;
	import Box2D.Dynamics.b2FixtureDef;
	import Common.ContactListener;
	import Common.Managers.SwfManager;
	import Common.Utils;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.ByteArray;
	import Game.GameStates.GameState;
	import Game.World;
	/**
	 * ...
	 * @author Yevgeniy Logachev
	 */
	public class Background extends GameObject
	{
		public  static var 	m_swfPath:String 				= Settings.pathRes + "swf/Backgrounds.swf";
		public 	static var 	m_BackgroundTypes:Array 		= ["Back1", "Back3", "Back2"];//, "Background2", "Background3", "Background4", "Background5", "Background6", "Background7", "Background8", "Background9"];
		
		public function Background(startX:int, startY:int, type:int) 
		{
			super(startX, startY, 0, m_swfPath, m_BackgroundTypes, type, false, false);
			World.instance.backgroundLayer.addChild(this);
			
			gameObjects.push(this);
			//this.cacheAsBitmap = true;
		}
		
		public static function deserialize(data:ByteArray):Background
		{
			var startX:int = data.readInt();
			var startY:int = data.readInt();
			var type:int = data.readInt();
			
			return new Background(startX, startY, type);
		}
		
		override public function serialize(data:ByteArray):void
		{
			data.writeInt(x);
			data.writeInt(y);
			data.writeInt(m_indxObj);
		}
		
		public static function loadResource(funcHandler:Function):void
		{
			SwfManager.instance.load(m_swfPath, funcHandler);
		}
		
		public static function isLoaded():Boolean
		{
			return SwfManager.instance.isLoaded(m_swfPath);
		}
		
		override public function update():void
		{
			super.update();
		}
	}

}